package com.wyh.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;

/**
 * @Author suolong
 * @Date 2024/3/4 14:22
 * @Version 1.5
 */
@Slf4j
@Configuration
public class MyMateObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("mybatisplus公共字段填充[insert]...");
        metaObject.setValue("createTime", LocalDateTime.now());//创建时间
        metaObject.setValue("updateTime", LocalDateTime.now());//修改时间
        metaObject.setValue("createUserId",  "888888");//创建人ID
        metaObject.setValue("updateUserId",  "888888");//修改人ID
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("mybatisplus公共字段填充[update]...");
        metaObject.setValue("updateTime", LocalDateTime.now());//修改时间
        metaObject.setValue("updateUserId",  "888888");//修改人ID
    }
}
